################################################
#
# Events for Spain
#
# ID 60000 - 69999 is reserved
#
#
#################################################
#
# Written by Sara Wendel-rtqvist

### The Central Junta of Aranjuez ###
country_event = {
	id = 60000
	title = "EVTNAME60000"
	desc = "EVTDESC60000"
	
	fire_only_once = yes
	
	trigger = {
		tag = SPA
		vassal_of = FRA
		NOT = {
			has_country_modifier = central_junta
		}
		NOT = {
			has_country_flag = junta_resigns_flag
		}
		NOT = {
			has_country_modifier = cortez_constitution
		}
		169 = { #Aranjuez
			controlled_by = SPA
		}
	}
	
	mean_time_to_happen = {
		months = 25
	}
	
	option = {
		name = "EVTOPT_OK"
		add_country_modifier = {
			name = central_junta
			duration = -1
		}
	}
}

### Uprising in Madrid ###
country_event = {
	id = 60010
	title = "EVTNAME60010"
	desc = "EVTDESC60010"
	
	fire_only_once = yes
	
	trigger = {
		tag = SPA
		alliance_with = FRA
		any_owned_province = {
			revolt_risk = 1
		}
	}
	
	mean_time_to_happen = {
		months = 25
		
		modifier = {
			factor = 0.9
			170 = {
				revolt_risk = 2
			}
		}
		modifier = {
			factor = 0.9
			170 = {
				revolt_risk = 3
			}
		}
		modifier = {
			factor = 0.9
			170 = {
				revolt_risk = 4
			}
		}
		modifier = {
			factor = 0.9
			170 = {
				revolt_risk = 5
			}
		}
	}
	
	option = {
		name = "EVTOPT_OK"
		170 = {
			create_revolt = 2
		}
		random_owned = {
			limit = {
				NOT = {
					province_id = 170
				}
			}
			create_revolt = 2
		}
		random_owned = {
			limit = {
				NOT = {
					province_id = 170
				}
			}
			create_revolt = 2
		}
	}
}

### The Junta resigns ###
country_event = {
	id = 60020
	title = "EVTNAME60020"
	desc = "EVTDESC60020"
	
	fire_only_once = yes
	
	trigger = {
		tag = SPA
		war_with = FRA
		has_country_modifier = central_junta
		any_owned_province = {
			OR = {
				controlled_by = FRA
				has_siege = yes
			}
		}
	}
	
	mean_time_to_happen = {
		months = 25
	}
	
	option = {
		name = "EVTOPT_OK"
		set_country_flag = junta_resigns_flag
		remove_country_modifier = central_junta
	}
}

### The Cortes opened ###
country_event = {
	id = 60030
	title = "EVTNAME60030"
	desc = "EVTDESC60030"
	
	fire_only_once = yes
	
	trigger = {
		tag = SPA
		OR = {
			war_with = FRA
			war = yes
		}
		has_country_flag = junta_resigns_flag
		NOT = {
			has_country_modifier = cortez_constitution
		}
	}
	
	mean_time_to_happen = {
		months = 25
	}
	
	option = {
		name = "EVTOPT_OK"
		clr_country_flag = junta_resigns_flag
		add_country_modifier = {
			name = cortez_constitution
			duration = 365
		}
	}
}

### End of the Inquisition ###
country_event = {
	id = 60040
	title = "EVTNAME60040"
	desc = "EVTDESC60040"
	
	fire_only_once = yes
	
	trigger = {
		tag = SPA
		OR = {
			has_country_flag = spa_king_joseph_bonaparte_flag
			has_country_flag = spa_napoleon_bonaparte_flag
			has_country_flag = spa_king_joachim_murat_flag
		}
		NOT = {
			has_country_flag = end_inquisition_flag
		}
	}
	
	mean_time_to_happen = {
		months = 25
	}
	
	option = {
		name = "EVTOPT_OK"
		set_country_flag = end_inquisition_flag
		add_country_modifier = {
			name = end_inquisition
			duration = 365
		}
	}
}

### Bayonne Statute - Joseph Bonaparte, king of Spain ###
country_event = {
	id = 60050
	title = "EVTNAME60050"
	desc = "EVTDESC60050"
	
	major = yes
	
	fire_only_once = yes
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPT_OK"
		add_leader = 24227
		define_ruler = {
			name = "Joseph Bonaparte"
			picture = "NAP_Joseph_Bonaparte"
			MIL = 4
			DIP = 7
			ADM = 6
		}
		any_owned = {
			limit = {
				controlled_by = FRA
			}
			revolt_risk = 25
		}
	}
}

### Bayonne Statute - Joachim Murat, king of Spain ###
country_event = {
	id = 60051
	title = "EVTNAME60051"
	desc = "EVTDESC60051"
	
	major = yes
	
	fire_only_once = yes
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPT_OK"
		add_leader = 24327
		define_ruler = {
			name = "Joachim Murat"
			picture = "NAP_Joachim_Murat"
			ADM = "6"
			DIP = "5"
			MIL = "5"
		}
		any_owned = {
			limit = {
				controlled_by = FRA
			}
			revolt_risk = 25
		}
	}
}

### Bayonne Statute - Napoleon Bonaparte, king of Spain ###
country_event = {
	id = 60052
	title = "EVTNAME60052"
	desc = "EVTDESC60052"
	
	major = yes
	
	fire_only_once = yes
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPT_OK"
		add_leader = 24330
		define_ruler = {
			name = "Napoleon Bonaparte"
			picture = "FRA_NapoleonI"
			MIL = 9
			DIP = 7
			ADM = 9
		}
		any_owned = {
			limit = {
				controlled_by = FRA
			}
			revolt_risk = 25
		}
	}
}

### Return of the Balmis Expedition ###
country_event = {
	id = 60060
	title = "EVTNAME60060"
	desc = "EVTDESC60060"
	
	fire_only_once = yes
	
	trigger = {
		tag = SPA
		NOT = {
			has_country_modifier = success_balmis_expedition
		}
	}
	
	mean_time_to_happen = {
		months = 25
	}
	
	option = {
		name = "EVTOPT_OK"
		add_country_modifier = {
			name = success_balmis_expedition
			duration = 365
		}
	}
}

### Mutiny of Aranjuez ###
country_event = {
	id = 60070
	title = "EVTNAME60070"
	desc = "EVTDESC60070"
	
	fire_only_once = yes
	
	trigger = {
		tag = SPA
		truce_with = FRA
		NOT = {
			has_country_flag = spa_king_joseph_bonaparte_flag
		}
		NOT = {
			has_country_flag = spa_napoleon_bonaparte_flag
		}
		NOT = {
			has_country_flag = spa_king_joachim_murat_flag
		}
		NOT = {
			has_country_flag = king_ferdinand_flag
		}
		169 = { #Aranjuez
			controlled_by = SPA
		}
	}
	
	mean_time_to_happen = {
		months = 25
		
		modifier = {
			factor = 0.9
			169 = {
				revolt_risk = 1
			}
		}
		modifier = {
			factor = 0.9
			169 = {
				revolt_risk = 2
			}
		}
		modifier = {
			factor = 0.9
			169 = {
				revolt_risk = 3
			}
		}
		modifier = {
			factor = 0.9
			169 = {
				revolt_risk = 4
			}
		}
	}
	
	option = {
		name = "EVTOPTA60070" #Dismiss the minister
		prestige = 10
		169 = {
			create_revolt = 1
		}
	}
	option = {
		name = "EVTOPTB60070" #This should make Fernando VII king (ID 55062)
		169 = {
			revolt_risk = -0.5
		}
		set_country_flag = king_ferdinand_flag
	}
	option = {
		name = "EVTOPTC60070" #Do nothing
		169 = {
			create_revolt = 2
		}
	}
}

### Fernando Sor ###
country_event = {
	id = 60080
	title = "EVTNAME60080"
	desc = "EVTDESC60080"
	
	fire_only_once = yes
	
	trigger = {
		tag = SPA
		war_with = FRA
		NOT = {
			has_country_modifier = patriotic_songs
		}
	}
	
	mean_time_to_happen = {
		months = 25
	}
	
	option = {
		name = "EVTOPTA60080"
		add_country_modifier = {
			name = patriotic_songs
			duration = 365
		}
	}
	option = {
		name = "EVTOPTB60080"
		relation = {
			who = FRA
			value = 25
		}
		random_owned = {
			random_list = {
				50 = { }
				20 = {
					revolt_risk = 0.25
				}
				20 = {
					revolt_risk = 0.5
				}
				10 = {
					create_revolt = 1
				}
			}
		}
	}
}

### Agustina de Aragn ###
country_event = {
	id = 60085
	title = "EVTNAME60085"
	desc = "EVTDESC60085"
	
	fire_only_once = yes
	
	trigger = {
		tag = SPA
		war_with = FRA
		any_owned_province = {
			has_siege = yes
		}
	}
	
	mean_time_to_happen = {
		months = 25
	}
	
	option = {
		name = "EVTOPTA60085"
		random_owned = {
			limit = {
				has_siege = yes
			}
			add_province_modifier = {
				name = augustina_de_aragon
				duration = 365
			}
		}
	}
}

### Francisco Goya ###
country_event = {
	id = 60090
	title = "EVTNAME60090"
	desc = "EVTDESC60090"
	
	fire_only_once = yes
	
	trigger = {
		tag = SPA
		OR = {
			war_with = FRA
			truce_with = FRA
			alliance_with = FRA
			vassal_of = FRA
		}
	}
	
	mean_time_to_happen = {
		months = 25
	}
	
	option = {
		name = "EVTOPT_OK"
		idea_points = 25
	}
}

### Spanish American wars of independence ###
country_event = {
	id = 60095
	title = "EVTNAME60095"
	desc = "EVTDESC60095"
	
	major = yes
	
	fire_only_once = yes
	
	trigger = {
		tag = SPA
		vassal_of = FRA
		OR = {
			has_country_flag = spa_king_joseph_bonaparte_flag
			has_country_flag = spa_napoleon_bonaparte_flag
			has_country_flag = spa_king_joachim_murat_flag
		}
		OR = {
			has_country_modifier = central_junta
			has_country_flag = junta_resigns_flag
			has_country_modifier = cortez_constitution
		}
		NOT = {
			has_country_flag = spanish_american_wars_independence_flag
		}
		NOT = {
			has_country_modifier = spanish_american_wars_independence
		}
	}
	
	mean_time_to_happen = {
		months = 25
	}
	
	option = {
		name = "EVTOPT_OK"
		set_country_flag = spanish_american_wars_independence_flag
		remove_country_modifier = spanish_american_holdings
		add_country_modifier = {
			name = spanish_american_wars_independence
			duration = -1
		}
	}
}

# Government Junta of Chile
country_event = {
	id = 60096
	title = "EVTNAME60096"
	desc = "EVTDESC60096"
	
	fire_only_once = yes
	
	trigger = {
		tag = SPA
		has_country_flag = spanish_american_wars_independence_flag
		has_country_modifier = spanish_american_wars_independence
		NOT = {
			has_country_flag = chile_junta_flag
		}
	}
	
	mean_time_to_happen = {
		months = 25
	}
	
	option = {
		name = "EVTOPT_OK"
		set_country_flag = chile_junta_flag
		prestige = 10
	}
}
	
# May Revolution
country_event = {
	id = 60097
	title = "EVTNAME60097"
	desc = "EVTDESC60097"
	
	fire_only_once = yes
	
	trigger = {
		tag = SPA
		month = 4
		NOT = {
			month = 6
		}
		has_country_flag = spanish_american_wars_independence_flag
		has_country_modifier = spanish_american_wars_independence
		OR = {
			has_country_flag = junta_resigns_flag
			has_country_modifier = cortez_constitution
		}
		NOT = {
			has_country_flag = may_revolution_flag
		}
	}
	
	mean_time_to_happen = {
		months = 60
	}
	
	option = {
		name = "EVTOPT_OK"
		prestige = 10
		set_country_flag = may_revolution_flag
	}
}

# Grito de Dolores
country_event = {
	id = 60098
	title = "EVTNAME60098"
	desc = "EVTDESC60098"
	
	fire_only_once = yes
	
	trigger = {
		tag = SPA
		has_country_flag = spanish_american_wars_independence_flag
		has_country_modifier = spanish_american_wars_independence
	}
	
	mean_time_to_happen = {
		months = 60
	}
	
	option = {
		name = "EVTOPT_OK"
		prestige = 10
	}
}

# Colombian Declaration of Independence
country_event = {
	id = 60099
	title = "EVTNAME60099"
	desc = "EVTDESC60099"
	
	fire_only_once = yes
	
	trigger = {
		tag = SPA
		has_country_flag = spanish_american_wars_independence_flag
		has_country_modifier = spanish_american_wars_independence
		OR = {
			has_country_flag = junta_resigns_flag
			has_country_modifier = cortez_constitution
		}
	}
	
	mean_time_to_happen = {
		months = 60
	}
	
	option = {
		name = "EVTOPT_OK"
		prestige = 10
	}
}

# First Republic of Venezuela
country_event = {	
	id = 60100
	title = "EVTNAME60100"
	desc = "EVTDESC60100"
	
	fire_only_once = yes
	
	trigger = {
		tag = SPA
		has_country_flag = spanish_american_wars_independence_flag
		has_country_modifier = spanish_american_wars_independence
	}
	
	mean_time_to_happen = {
		months = 60
	}
	
	option = {
		name = "EVTOPT_OK"
		prestige = 10
	}
}

# Cry of Asencio
country_event = {
	id = 60101
	title = "EVTNAME60101"
	desc = "EVTDESC60101"
	
	fire_only_once = yes
	
	trigger = {
		tag = SPA
		has_country_flag = spanish_american_wars_independence_flag
		has_country_modifier = spanish_american_wars_independence
		has_country_flag = may_revolution_flag
	}
	
	mean_time_to_happen = {
		months = 60
	}
	
	option = {
		name = "EVTOPT_OK"
		prestige = 10
	}
}

# Primer grito de independencia
country_event = {
	id = 60102
	title = "EVTNAME60102"
	desc = "EVTDESC60102"
	
	fire_only_once = yes
	
	trigger = {
		tag = SPA
		has_country_flag = spanish_american_wars_independence_flag
		has_country_modifier = spanish_american_wars_independence
	}
	
	mean_time_to_happen = {
		months = 60
	}
	
	option = {
		name = "EVTOPT_OK"
		prestige = 10
	}
}


### Spanish Holdings in America ###
country_event = {
	id = 60105
	title = "EVTNAME60105" 
	desc = "EVTDESC60105"
	
	fire_only_once = yes
	
	trigger = { 
		tag = SPA
	}
	
	mean_time_to_happen = {
		days = 1
	}
	
	option = {
		name = "EVTOPTOK"
		add_country_modifier = {
			name = spanish_american_holdings
			duration = -1
		}
	}
}
